#include <cctype>
#include <cstdio>
using namespace std;

int cky_read(){
	int res = 0;
	char ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)){
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	}
	return res;
}

struct fruit{
	int id;
	bool isapple;
};

int n,tmp,cnt;
fruit A[200010];

int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	n = cky_read();
	cnt = n;
	for (int i = 1;i <= n;i++){
		A[i].id = i;
		tmp = cky_read();
		if (tmp == 1) A[i].isapple = true;
		else A[i].isapple = false;
	}
	while (cnt > 0){
		if (cnt == 1){
			printf("%d",A[1].id);
			return 0;
		}
		while (A[1].isapple != A[2].isapple){
			printf("%d ",A[1].id);
			for (int i = 2;i <= cnt;i++) A[i - 1] = A[i];
			cnt--;
		}
		printf("%d ",A[1].id);
		for (int i = 2;i <= cnt;i++) A[i - 1] = A[i];
		cnt--;
		for (int i = 2;i < cnt;i++){
			if (A[i].isapple != A[i - 1].isapple){
				printf("%d ",A[i + 1].id);
				for (int j = i + 1;j <= cnt;j++){
					A[j] = A[j + 1];
				}
				i++;
				cnt--;
			}
		}
		printf("\n");
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
